<template>
  <div class="home-container">
    <!-- 全屏轮播图 -->
    <el-carousel :interval="4000" height="500px" class="full-width-carousel">
      <el-carousel-item v-for="item in carouselItems" :key="item.id">
        <div class="carousel-image-container">
          <img :src="item.image" alt="" class="carousel-image">
          <div class="carousel-overlay"></div>
          <div class="carousel-content">
            <h1>{{ item.title }}</h1>
            <p>{{ item.description }}</p>
            <el-button type="primary" size="large" @click="$router.push('/user/dish')">立即点餐</el-button>
          </div>
        </div>
      </el-carousel-item>
    </el-carousel>

    <!-- 特色介绍 -->
    <div class="features-section">
      <div class="features-container">
        <div class="feature-item">
          <div class="feature-icon">
            <i class="el-icon-dish"></i>
          </div>
          <h3>精致美食</h3>
          <p>品味生活，享受美食</p>
        </div>
        <div class="feature-item">
          <div class="feature-icon">
            <i class="el-icon-house"></i>
          </div>
          <h3>舒适环境</h3>
          <p>温馨氛围，放松身心</p>
        </div>
        <div class="feature-item">
          <div class="feature-icon">
            <i class="el-icon-service"></i>
          </div>
          <h3>优质服务</h3>
          <p>贴心周到，宾至如归</p>
        </div>
      </div>
    </div>

    <!-- 推荐菜品部分 -->
    <div class="section dish-section">
      <div class="section-container">
        <h2 class="section-title">推荐菜品</h2>
        <el-row :gutter="30">
          <el-col :xs="24" :sm="12" :md="6" v-for="dish in recommendedDishes" :key="dish.id">
            <el-card class="dish-card">
              <div class="dish-info">
                <h3>{{ dish.name }}</h3>
                <p class="dish-description">{{ dish.description }}</p>
                <div class="dish-price-action">
                  <span class="dish-price">¥{{ dish.price }}</span>
                  <el-button type="primary" size="small" @click="addToCart(dish)">加入购物车</el-button>
                </div>
              </div>
            </el-card>
          </el-col>
        </el-row>
      </div>
    </div>

    <!-- 餐厅介绍部分 -->
    <div class="section about-section">
      <div class="section-container">
        <h2 class="section-title">餐厅介绍</h2>
        <el-row :gutter="30">
          <el-col :xs="24" :md="12">
            <div class="about-content">
              <h3>人格魅力餐厅</h3>
              <p>人格魅力餐厅是一家以提供高品质美食和优质服务为宗旨的餐厅。我们致力于为顾客提供舒适的用餐环境和美味的菜品，让每一位顾客都能享受到愉快的用餐体验。</p>
              <p>我们的厨师团队由多位经验丰富的大厨组成，他们精心挑选食材，用心烹饪每一道菜品，确保每一位顾客都能品尝到最美味的食物。</p>
              <p>我们的服务团队热情周到，随时为顾客提供帮助，让顾客感受到宾至如归的温暖。</p>
            </div>
          </el-col>
          <el-col :xs="24" :md="12">
            <div class="about-image-container">
              <div class="about-image-placeholder">
                <h3>人格魅力餐厅</h3>
                <p>提供各种美食，秉承顾客至上的服务理念</p>
              </div>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { ElMessage } from 'element-plus'

// 轮播图数据
const carouselItems = ref([
  {
    id: 1,
    title: '精致美食',
    description: '品味生活，享受美食',
    image: 'https://img.zcool.cn/community/01f1c85d145963a8012051cd2c8a2a.jpg@1280w_1l_2o_100sh.jpg'
  },
  {
    id: 2,
    title: '舒适环境',
    description: '温馨氛围，放松身心',
    image: 'https://img.zcool.cn/community/01a0b75d145963a8012051cdb52c86.jpg@1280w_1l_2o_100sh.jpg'
  },
  {
    id: 3,
    title: '优质服务',
    description: '贴心周到，宾至如归',
    image: 'https://img.zcool.cn/community/01e0c65d145963a8012051cd0a5a3a.jpg@1280w_1l_2o_100sh.jpg'
  }
])

// 推荐菜品数据
const recommendedDishes = ref([
  {
    id: 1,
    name: '红烧肉',
    description: '精选五花肉，红烧入味，肥而不腻',
    price: 68,
    image: 'https://img.zcool.cn/community/01f1c85d145963a8012051cd2c8a2a.jpg@1280w_1l_2o_100sh.jpg'
  },
  {
    id: 2,
    name: '清蒸鱼',
    description: '新鲜活鱼，清蒸保留原汁原味',
    price: 98,
    image: 'https://img.zcool.cn/community/01a0b75d145963a8012051cdb52c86.jpg@1280w_1l_2o_100sh.jpg'
  },
  {
    id: 3,
    name: '宫保鸡丁',
    description: '鸡肉鲜嫩，花生香脆，口感丰富',
    price: 48,
    image: 'https://img.zcool.cn/community/01e0c65d145963a8012051cd0a5a3a.jpg@1280w_1l_2o_100sh.jpg'
  },
  {
    id: 4,
    name: '水煮鱼',
    description: '麻辣鲜香，鱼肉嫩滑，回味无穷',
    price: 88,
    image: 'https://img.zcool.cn/community/01f1c85d145963a8012051cd2c8a2a.jpg@1280w_1l_2o_100sh.jpg'
  }
])

// 添加到购物车
const addToCart = (dish: any) => {
  ElMessage.success(`已将 ${dish.name} 加入购物车`)
}
</script>

<style scoped>
.home-container {
  width: 100%;
  overflow-y: auto;
  padding: 0;
  margin: 0;
}

/* 全宽轮播图样式 */
.full-width-carousel {
  width: 100%;
  margin-top: -20px;
  margin-bottom: 0;
}

.carousel-image-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.carousel-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.carousel-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
}

.carousel-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: white;
  width: 80%;
  max-width: 800px;
}

.carousel-content h1 {
  font-size: 3rem;
  margin-bottom: 1rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.carousel-content p {
  font-size: 1.5rem;
  margin-bottom: 2rem;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* 特色介绍部分 */
.features-section {
  background-color: #f8f9fa;
  padding: 60px 0;
  width: 100%;
}

.features-container {
  display: flex;
  justify-content: space-around;
  max-width: 1200px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.feature-item {
  text-align: center;
  padding: 20px;
  width: 300px;
  margin-bottom: 20px;
}

.feature-icon {
  font-size: 3rem;
  margin-bottom: 20px;
  color: #409EFF;
}

.feature-item h3 {
  font-size: 1.5rem;
  margin-bottom: 10px;
  color: #333;
}

.feature-item p {
  color: #666;
}

/* 通用部分样式 */
.section {
  padding: 60px 0;
  width: 100%;
}

.dish-section {
  background-color: white;
}

.about-section {
  background-color: #f8f9fa;
}

.section-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.section-title {
  font-size: 2rem;
  text-align: center;
  margin-bottom: 40px;
  position: relative;
  padding-bottom: 15px;
}

.section-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background-color: #409EFF;
}

/* 菜品卡片样式 */
.dish-card {
  margin-bottom: 30px;
  transition: all 0.3s;
  border: none;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  height: 100%;
}

.dish-card:hover {
  transform: translateY(-10px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}

.dish-info {
  padding: 20px;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.dish-info h3 {
  margin-top: 0;
  font-size: 1.2rem;
  color: #333;
  font-weight: bold;
}

.dish-description {
  color: #666;
  margin: 15px 0;
  min-height: 60px;
  line-height: 1.5;
  flex-grow: 1;
}

.dish-price-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 15px;
}

.dish-price {
  color: #f56c6c;
  font-size: 1.5rem;
  font-weight: bold;
}

/* 关于我们部分样式 */
.about-content {
  padding: 20px;
}

.about-content h3 {
  font-size: 1.8rem;
  margin-bottom: 20px;
  color: #333;
}

.about-content p {
  margin-bottom: 15px;
  line-height: 1.6;
  color: #555;
}

.about-image-container {
  width: 100%;
  height: 400px;
  border-radius: 8px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.about-image-placeholder {
  width: 100%;
  height: 100%;
  background-color: #f0f2f5;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 20px;
}

.about-image-placeholder h3 {
  font-size: 2rem;
  margin-bottom: 15px;
  color: #333;
}

.about-image-placeholder p {
  font-size: 1.2rem;
  color: #666;
  max-width: 80%;
}

/* 响应式调整 */
@media (max-width: 768px) {
  .carousel-content h1 {
    font-size: 2rem;
  }

  .carousel-content p {
    font-size: 1rem;
  }

  .feature-item {
    width: 100%;
  }

  .about-image-container {
    height: 300px;
    margin-top: 20px;
  }
}
</style>
